{template 'common/header'}
<style>
    a:hover {
        color: white;
        text-decoration: underline;
    }
</style>
<!--<script>-->
    <!--$(function(){-->
        <!--$(".to_change").on('click',function(){-->
            <!--var goods_id = $(this).attr('goods_id');-->
            <!--$("#change-goods-id").val(goods_id);-->
        <!--});-->
        <!--$(".key").keyup(function(){-->
            <!--var key = $(this).val();-->
            <!--var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_members'))}";-->
            <!--$.ajax({-->
                <!--type : 'post',-->
                <!--url : url,-->
                <!--data : {'key_word' : key},-->
                <!--success : function(data){-->
                    <!--$("#member-list").html(data);-->
                <!--}-->
            <!--});-->
        <!--});-->
        <!--$(".change").on('click',function(){-->
            <!--var goods_id = $("#change-goods-id").val();-->
            <!--var member = $("#member-list").val();-->
            <!--alert(goods_id+"|"+member);-->
        <!--});-->
    <!--});-->

<!--</script>-->
<script>
    $(function(){
        $(".clear-day").on('click',function(){
            $("#day").val('');
        });
    });
</script>
<ul class="nav nav-tabs">
    <li {if $slow_pay == 0} class="active" {/if} ><a href="{php echo $this->createWebUrl('cashier')}">未收款</a></li>
    <li {if $slow_pay == 1} class="active" {/if}><a href="{php echo $this->createWebUrl('cashier', array('slow_pay'=>1))}">月结单</a></li>
    <li ><a href="{php echo $this->createWebUrl('cashier', array('op'=>'had_get'))}">未审核已收款</a></li>
    <li  ><a href="{php echo $this->createWebUrl('cashier', array('op'=>'express'))}">服务社</a></li>
    <li ><a href="{php echo $this->createWebUrl('cashier', array('op'=>'express','slow_pay' => 1))}">服务社月结单</a></li>
</ul>
<div class="main" style="padding: 0px 10px 0px 10px;">
    <div class="row">
        <div class="col-xs-2">
            <select class="form-control" id="region_id">
                <option value="-1">到货区域</option>
                {loop $regions $region}
                <option value="{$region['id']}" {if $region['id'] == $region_id} selected="selected" {/if}>{$region['name']}</option>
                {/loop}
            </select>
        </div>
        <div class="col-xs-2">
            <input type="text" placeholder="客户名称/电话/助记码" class="form-control key" value="{$key_word}" id="key" />
        </div>
        <div class="col-xs-3">
            <input type="date" value="{$day}" id="day" class="form-control" />
            <!--<div class="col-xs-5"><input type="date" value="{$end_day}" id="end_day" class="form-control" /></div>-->
        </div>
        <div class="col-xs-2">
            <button class="btn btn-default clear-day">清空日期</button>
        </div>
        <div class="col-xs-2">
            <select class="form-control" id="pay_status">
                <option value="1">未收款</option>
                <option value="2" {if $pay_status == 2} selected="selected" {/if}>已收款</option>
            </select>
        </div>
        <div class="col-xs-1">
            <button class="btn btn-primary find" >搜索</button>
        </div>
    </div>

    <br />
    {if $my_orders}
    {loop $my_orders $orders}

        <div class="panel panel-primary">
            <div class="panel-heading">

                <div class="panel-title row">
                    <a href="{php echo $this->createWebUrl('cashier',array('op' => 'member_detail','member_id' => $orders['member_id'], 'slow_pay' => $slow_pay,'day' => $orders['day'], 'pay_status' => $pay_status))}">
                    <div class="col-xs-2">{$orders['member']}{if $orders['remark']}({$orders['remark']}){/if}</div>
                    </a>
                    {if $orders['phone']}
                    <div class="col-xs-4">
                        <a href="tel:{$orders['phone']}"> 电话：{$orders['phone']}</a>
                    </div>
                    {else}
                    <a href="{php echo $this->createWebUrl('cashier',array('op' => 'member_detail','member_id' => $orders['member_id'], 'slow_pay' => $slow_pay,'day' => $orders['day'], 'pay_status' => $pay_status))}">
                        <div class="col-xs-4"></div>
                    </a>
                    {/if}
                    <a href="{php echo $this->createWebUrl('cashier',array('op' => 'member_detail','member_id' => $orders['member_id'], 'slow_pay' => $slow_pay,'day' => $orders['day'], 'pay_status' => $pay_status))}">
                        <div class="col-xs-2">
                            {if $pay_status == 1}
                            应收：{$orders['receivable']}
                            {else}
                            应收：0
                            {/if}
                        </div>
                    </a>
                    <a href="{php echo $this->createWebUrl('cashier',array('op' => 'member_detail','member_id' => $orders['member_id'], 'slow_pay' => $slow_pay,'day' => $orders['day'], 'pay_status' => $pay_status))}">
                    <div class="col-xs-4">
                        <span style="float: right">{$orders['day']}</span>
                    </div>

                </div>
                </a>

            </div>
        </div>

    <!--<div class="panel panel-primary">-->
        <!--<div class="panel-heading">-->
            <!--<div class="panel-title">-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="panel-body">-->
            <!--<table class="table">-->
                <!--<tr>-->
                    <!--<th>商品</th>-->
                    <!--<th>数量</th>-->
                    <!--<th>运费单价</th>-->
                    <!--<th>代付款</th>-->
                    <!--<th>已收运费</th>-->
                    <!--<th>已收代付款</th>-->
                    <!--<th colspan="5" align="center"></th>-->
                    <!--&lt;!&ndash;<th>手续费</th>&ndash;&gt;-->
                <!--</tr>-->
                <!--{loop $orders['goods'] $good}-->
                <!--<tr>-->
                    <!--<td>{$good['goods_name']}</td>-->
                    <!--<td>{$good['numbers']}{$good['unit']}</td>-->
                    <!--<td>{$good['freight']}</td>-->
                    <!--<td>{$good['gen_pay']}</td>-->
                    <!--<td>{$good['had_freight']}</td>-->
                    <!--<td>{$good['had_gen_pay']}</td>-->
                    <!--&lt;!&ndash;<td>{$good['charge']}</td>&ndash;&gt;-->

                    <!--<td colspan="5" align="center">-->
                        <!--<button class="btn btn-success all" goods_id="{$good['id']}">收齐</button>-->
                        <!--<button class="btn btn-primary to_get_money" data-toggle="modal" data-target="#myModal" goods_id="{$good['id']}">收款</button>-->
                        <!--<button class="btn btn-warning" onclick="delay({$good['id']});">缓收</button>-->
                            <!--<button class="btn btn-danger to_change" data-toggle="modal" goods_id="{$good['id']}" data-target="#myModal2">更换收款客户</button>-->
                    <!--</td>-->
                <!--</tr>-->
                <!--{/loop}-->
            <!--</table>-->
            <!--<div>-->
                <!--总应收：{$orders['total_price']}-->
            <!--</div>-->
            <!--<button class="btn btn-success" onclick="get_all({$orders['member_id']});" >全部收齐</button>-->
        <!--</div>-->
    <!--</div>-->
    {/loop}
    <div>{$pager}</div>
    {else}
    <div class="alert alert-warning">您该区域还未有未收款</div>
    {/if}
</div>
<!-- 变更客户 -->
<!--<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">-->
    <!--<div class="modal-dialog" role="document">-->
        <!--<div class="modal-content">-->
            <!--<div class="modal-header">-->
                <!--<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>-->
                <!--<h4 class="modal-title" id="myModalLabel2">变更收款客户</h4>-->
            <!--</div>-->
            <!--<div class="modal-body">-->
                <!--<div class="row">-->
                    <!--<div class="col-xs-4"></div>-->
                    <!--<div class="col-xs-4">-->
                        <!--<input type="text" placeholder="客户名/助记码/电话" class="form-control key" />-->
                    <!--</div>-->
                    <!--<div class="col-xs-4"></div>-->
                <!--</div>-->
                <!--<br />-->
                <!--<div class="row">-->
                    <!--<div class="col-xs-4"></div>-->
                    <!--<div class="col-xs-4">-->
                        <!--<select class="form-control" id="member-list">-->
                            <!--<option>请先输入客户搜索条件</option>-->
                        <!--</select>-->
                    <!--</div>-->
                    <!--<div class="col-xs-4"></div>-->
                <!--</div>-->
            <!--</div>-->
            <!--<div class="modal-footer">-->
                <!--<input type="hidden" value="0" id="change-member-id" />-->
                <!--<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>-->
                <!--<button type="button" class="btn btn-primary change">确定</button>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
<!--</div>-->

<!-- Modal -->
<!--<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">-->
    <!--<div class="modal-dialog" role="document">-->
        <!--<div class="modal-content">-->
            <!--<div class="modal-header">-->
                <!--<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>-->
                <!--<h4 class="modal-title" id="myModalLabel">收款内容</h4>-->
            <!--</div>-->
            <!--<div class="modal-body">-->
                <!--<input type="text" class="form-control" placeholder="收到运费" id="had_freight" />-->
                <!--<br />-->
                <!--<input type="text" class="form-control" placeholder="收到代付款" id="had_gen" />-->
                <!--<br />-->
                <!--<input type="text" class="form-control" placeholder="备注" id="had_remark" />-->
                <!--<input type="hidden" value="0" id="goods-id" />-->
            <!--</div>-->
            <!--<div class="modal-footer">-->
                <!--<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>-->
                <!--<button type="button" class="btn btn-primary pay">确定</button>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
<!--</div>-->
<!--<script>-->
    <!--$(function(){-->
        <!--$(".to_get_money").click(function(){-->
            <!--var goods_id = $(this).attr('goods_id');-->
            <!--$("#goods_id").val(goods_id);-->
        <!--});-->
        <!--$(".pay").click(function(){-->
            <!--var goods_id = $("#goods_id").val();-->
            <!--var had_freight = $("#had_freight").val();-->
            <!--var had_gen = $("#had_gen").val();-->
            <!--var had_remark = $("#had_remark").val();-->
            <!--var had_charge = $("#had_charge").val();-->
            <!--$.ajax({-->
                <!--type : "post",-->
                <!--url : "{php echo $this->createWebUrl('cashier',array('op' => 'get_money'))}",-->
                <!--data : {'goods_id' : goods_id, 'had_freight' : had_freight, 'had_gen' : had_gen, 'had_remark' : had_remark,'had_charge' : had_charge},-->
                <!--success : function(data){-->
                    <!--if(data == 111){-->
                        <!--location.reload();-->
                    <!--}else{-->
                        <!--alert(data);-->
                    <!--}-->
                <!--}-->
            <!--});-->
        <!--});-->
        <!--$(".all").click(function(){-->
            <!--var goods_id = $(this).attr('goods_id');-->
            <!--if(confirm("是否确定全部收齐？")){-->
                <!--$.ajax({-->
                    <!--type : "post",-->
                    <!--url : "{php echo $this->createWebUrl('cashier',array('op' => 'get_money'))}",-->
                    <!--data : {'goods_id' : goods_id, 'type' : 'all'},-->
                    <!--success : function(data){-->
                        <!--if(data == 111){-->
                            <!--location.reload();-->
                        <!--}else{-->
                            <!--alert(data);-->
                        <!--}-->
                    <!--}-->
                <!--});-->
            <!--}-->
        <!--});-->
        <!--$(".find").change(function(){-->
            <!--var region_id = $(this).val();-->
            <!--location.href="{php echo $this->createWebUrl('cashier',array('op' => 'index'))}&region_id="+region_id;-->
        <!--});-->
    <!--});-->
    <!--function delay(id){-->
        <!--if(confirm("是否确定设置成缓收？")){-->
            <!--$.ajax({-->
                <!--type : "post",-->
                <!--url : "{php echo $this->createWebUrl('cashier',array('op' => 'slow'))}",-->
                <!--data : {'id' : id},-->
                <!--success : function(data){-->
                    <!--location.reload();-->
                <!--}-->
            <!--});-->
        <!--}-->
    <!--}-->
    <!--function get_all(member_id){-->
        <!--if(confirm("一经确定无法修改，是否确定已经收取了所有的款项？")){-->
            <!--$.ajax({-->
                <!--type : 'post',-->
                <!--url : "{php echo $this->createWebUrl('cashier',array('op' => 'get_all'))}",-->
                <!--data : {'member_id' : member_id},-->
                <!--success : function(data){-->
                    <!--if(data == 111){-->
                        <!--location.reload();-->
                    <!--}else{-->
                        <!--alert(data);-->
                    <!--}-->
                <!--}-->
            <!--});-->
        <!--}-->
    <!--}-->
<!--</script>-->
<script>
    $(function(){
//        $(".find").change(function(){
//            find();
//        });
//        $(".key").on('keyup',function(){
//            find();
//        })
        $(".find").on('click',function(){
            find();
        });
    });
    function find(){
        var region_id = $("#region_id").val();
        var key = $("#key").val();
        var day = $("#day").val();
        var pay_status = $("#pay_status").val();
        var slow_pay = "{$slow_pay}";
//        var end_day = $("#end_day").val();
        location.href="{php echo $this->createWebUrl('cashier',array('op' => 'index'))}&region_id="+region_id+"&key="+key+"&day="+day+"&pay_status="+pay_status+"&slow_pay="+slow_pay+"&find=1";
    }
</script>
{template 'common/footer'}